package org.yege.algorithm.hash;

/**
 * 主程序
 */
public class HashMain {
    public static void main(String[] args) {
        String[] serverNodes=new String[]{
                "192.168.1.1"
                ,"192.168.1.2"
                ,"192.168.1.3"
                ,"192.168.1.4"
                ,"192.168.1.5"
                ,"192.168.1.6"
                ,"192.168.1.7"
                ,"192.168.1.8"
                ,"192.168.1.9"
                ,"192.168.1.10"};
        System.out.println("1.【一致性hash算法_不加入虚拟节点】100万kv数据量测试情况:");
        Hash hash=new ConsistentHash();
        for(String serverNode:serverNodes){
            hash.addServerNode(serverNode);
        }
        for(int key=1;key<=1000000;key++){
            hash.getServerNodeByKey(Integer.toString(key));
        }
        double sd=hash.getStandardDeviation();
        System.out.println("标准差:"+sd);

        System.out.println("--------------------------------------------");

        System.out.println("2.【一致性hash算法_加入虚拟节点】100万kv数据量测试情况:");
        Hash hash1=new ConsistentAndVirtualNodeHash();
        for(String serverNode:serverNodes){
            hash1.addServerNode(serverNode);
        }
        for(int key=1;key<=1000000;key++){
            hash1.getServerNodeByKey(Integer.toString(key));
        }
        double sd1=hash1.getStandardDeviation();
        System.out.println("标准差:"+sd1);

    }
}
